package org.example;

// 接收者类
public class Light {
    private boolean isOn = false;
    
    public void turnOn() {
        if (isOn) {
            System.out.println("电灯已经是打开状态了");
        } else {
            isOn = true;
            System.out.println("电灯打开了");
        }
    }
    
    public void turnOff() {
        if (!isOn) {
            System.out.println("电灯已经是关闭状态了");
        } else {
            isOn = false;
            System.out.println("电灯关闭了");
        }
    }
    
    public boolean isOn() {
        return isOn;
    }
} 